import requests
import imgkit
root = 'static/4K壁纸'
headers = {
    'User-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0'
}
thumbnail_response = requests.get('https://pic.netbian.com/uploads/allimg/251029/223829-176174870990a2.jpg', headers=headers)
print(thumbnail_response.content)
# 保存HTML
with open(f'{root}/temp.html', 'wb') as f:
    f.write(thumbnail_response.content)

# 转换为图片
imgkit.from_file(f'{root}/temp.html', f'{root}/output.jpg')